<template>
    <div class='approval'>
      <el-card class="box-card">
        <div class='title'>
          {{$t('OverdueCustomerList.title1')}}
        </div>
        <div class='menu-search'> 
            <div class='menu-title'>
              <div class='searchItem searchItem-date'>
                <span>{{$t('OverdueCustomerList.choiceTime')}}</span>
                <el-date-picker
                  size='small'
                  v-model="listQuery.startDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  :placeholder="$t('rule.beginDate')">
                </el-date-picker>
                <b>{{$t('approval.go')}}</b>
                <el-date-picker
                size='small'
                  v-model="listQuery.endDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  :placeholder="$t('rule.endDate')">
                </el-date-picker>
              </div>
              <div class="searchItem">
                <span>{{$t('OverdueCustomerList.channel')}}</span>
                <el-select v-model='listQuery.channel' size='small'>
                    <el-option
                    v-for='item in appChannel'
                    :key='item.channel'
                    :label='item.org_name'
                    :value='item.channel'>
                    </el-option>
                </el-select>
              </div>
            </div>
            <div class='menu-title-btn'>
                <button type='button' @click='search'>
                    {{$t('btn.query')}}
                </button>
                <button type='button' @click='reset'>
                    {{$t('btn.reset')}}
                </button>
                <button type='button' @click="handleDownload" :disabled="expDis" v-if="endApprGroup_btn_export">
                    {{$t('btn.export')}}
                </button>
            </div>
        </div>
      </el-card>
        <el-card class='box-card' style="margin-top: 10px;margin-bottom: 20px;">
          <div class='title'>
              {{$t('OverdueCustomerList.title2')}}
          </div>
          <el-table
              :sum-text="$t('EndApprReport.total')"
              v-loading="listLoading"
              ref='multipleTable'
              :data='tableData'
              tooltip-effect='dark'
              style='width: 100%'
              @selection-change='handleSelectionChange'
              border
              show-summary
              :summary-method="getSummaries"
              size='mini'>
              <el-table-column
                :label="$t('user.num')"
                header-align='center'
                align='center'
                width="60">
                <template slot-scope="scope">
                  <span>{{scope.row.index}}</span>
                </template>
              </el-table-column>
              <el-table-column
              header-align='center'
              align='center'
              prop='crtTime'
              :label="$t('approvalDetail.riskTime')">
              </el-table-column>
              <el-table-column
              header-align='center'
              align='center'
              prop='finalCheckGroup'
              :label="$t('EndApprReport.firstGroup')">
              </el-table-column>
              <el-table-column
              header-align='center'
              align='center'
              prop='approvalCount'
              :label="$t('ApprReport.groupHandle')">
              </el-table-column>
              <el-table-column
              header-align='center'
              align='center'
              prop='passCount'
              :label="$t('ApprReport.groupAdopt')">
              </el-table-column>
              <el-table-column
              header-align='center'
              align='center'
              prop='passRate'
              :label="$t('ApprReport.groupRate')">
              </el-table-column>
              <el-table-column
              header-align='center'
              align='center'
              prop='firstOverdueRate'
              :label="$t('ApprReport.firstOver')">
              </el-table-column>
          </el-table>
          <div class="pagination-container">
            <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="listQuery.page"
            :page-sizes="[5, 10, 20, 30]"
            :page-size="listQuery.limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
            </el-pagination>
          </div>
        </el-card>
    </div>
</template>

<script>
import { mapGetters } from 'vuex';
import { getChannels } from 'api/customQuery/index'
import { getRiskOverdueCustomerPage, getRiskOverdueCustomerExport } from 'api/RiskManager/OverdueCustomerList/index'
export default {
  data() {
    return {
      endApprGroup_btn_export: false,
      totalTrail: '',
      totalPass: '',
      totalPassPercent: '',
      totalOverDualPercent: '',
      listLoading: false,
      total: null,
      expDis: true,
      listQuery: {
        limit: 5,
        page: 1,
        // groupIds: '',
        // 审核员
        approvalUser: '',
        // 审核组
        groupIds: '',
        // 开始时间
        startDate: '',
        // 结束时间
        endDate: '',
        // 类型   1 终审报表(人)  2终审报表(组)  3终审报表(总)
        type: 2,
        // 1自动审批 2 人工审批
        approvalType: ''
      },
      tableData: [],
      multipleSelection: [],
      collGroup: [
        {
          groupId: '',
          groupName: this.$t('rule.all')
        }
      ]
    };
  },
  computed: {
    ...mapGetters(['elements', 'endApprGroupPage'])
  },
  created() {
    // this.getList();
    this.endApprGroup_btn_export = this.elements['overdueCustomerListDay:btn_export'];
  },
  methods: {
    // 点击导出
    handleDownload() {
      // this.listLoading = true;
      // epxortExsl(this.listQuery)
      // .then(response => {
      //   require.ensure([], () => {
      //     const { export_json_to_excel } = require('@/vendor/Export2Excel')
      //     const tHeader = [this.$t('approvalDetail.riskTime'), this.$t('EndApprReport.firstGroup'), this.$t('ApprReport.groupHandle'), this.$t('ApprReport.groupAdopt'), this.$t('ApprReport.groupRate'), this.$t('ApprReport.firstOver')];
      //     const filterVal = ['crtTime', 'finalCheckGroup', 'approvalCount', 'passCount', 'passRate', 'firstOverdueRate'];
      //     const list = response.data;
      //     const data = this.formatJson(filterVal, list)
      //     export_json_to_excel(tHeader, data, this.$t('EndApprReport.apprGroup'))
      //     this.listLoading = false;
      //   })
      // })
    },
    formatJson(filterVal, jsonData) {
      return jsonData.map(v => filterVal.map(j => v[j]))
    },
    getList() {
      // this.listLoading = true;
      // this.$store.dispatch('saveEndApprGroupPage', { path: this.$route.path, listQuery: this.listQuery });
      // pageGroup(this.listQuery)
      //   .then(response => {
      //     response = response.data
      //     response.page.records.forEach((item, index) => {
      //       item.index = index + (this.listQuery.page - 1) * this.listQuery.limit + 1
      //     })
      //     this.expDis = false;
      //     this.listLoading = false;
      //     this.tableData = response.page.records;
      //     this.total = response.page.total;
      //     this.approvalCount = response.approvalCount;
      //     this.passCount = response.passCount;
      //     this.passRate = response.passRate;
      //     this.firstOverdueRate = response.firstOverdueRate;
      //   })
    },
    // 查询
    search() {
      this.listQuery.page = 1;
      this.getList();
    },
    // 重置
    reset() {
      this.listQuery.limit = 5;
      this.listQuery.page = 1;
      this.listQuery.startDate = '';
      this.listQuery.endDate = '';
      this.listQuery.groupIds = [];
    },
    // 选中的数据
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handleSizeChange(val) {
      this.listQuery.limit = val;
      this.getList()
    },
    handleCurrentChange(val) {
      this.listQuery.page = val;
      this.getList()
    }
  }
};
</script>

<style scoped lang='scss'>
.title {
  line-height: 30px;
  font-size: 16px;
  display: flex;
  align-items: center;
  font-weight: bold;
}
.title:before{
  display: block;
  content: "";
  width: 3px;
  height: 16px;
  background-color: #309afe;
}
.title:before {
  margin-right: 8px;
}
::before {
  box-sizing: inherit;
  -webkit-tap-highlight-color: transparent;
}
.menu-title {
  width: 100%;
  box-sizing: border-box;
  background: #ffffff;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  .searchItem {
    display: flex;
    align-items: center;
    padding: 10px  0;
    span {
      display: inline-block;
      width: 100px;
      text-align: right;
      font-size: 12px;
      color: #5f5f61;
      padding-right: 5px;
    }
    div:nth-child(2) {
      width: 150px;
    }
  }
  .searchItem-date {
    display: flex;
    align-items: center;
    padding: 10px  0;
    b {
      margin: 0 10px;
      font-weight: normal;
      font-size: 12px;
      color: #5f5f61;
    }
    div {
       width: 150px;
    }
  }
}
.menu-title-btn {
  padding: 10px 0;
  box-sizing: border-box;
  button {
    padding: 0 20px;
    height: 28px;
    background: #20a0ff;
    color: #fff;
    outline: none;
    border-width: 0;
    border-radius: 4px;
    font-size: 12px;
    margin-left: 10px;
    &:nth-child(1) {
      margin-left: 0;
    }
    &:nth-child(2) {
      background: #ebf5ff;
      color: #20a0ff;
      border: 1px solid #abd5ff;
    }
  }
  button[disabled] {
    padding: 0 20px;
    height: 28px;
    background: #c1e0ff;
    color: #fafbff;
    outline: none;
    border-width: 0;
    border-radius: 4px;
    font-size: 12px;
  }
}
.menu-list {
  padding: 20px 0;
  box-sizing: border-box;
  button {
    padding: 0 20px;
    height: 28px;
    background: #20a0ff;
    color: #fff;
    outline: none;
    border-width: 0;
    border-radius: 4px;
    font-size: 12px;
    margin-left: 10px;
    &:nth-child(1) {
      margin-left: 0;
    }
  }
  button[disabled] {
    padding: 0 20px;
    height: 28px;
    background: #c1e0ff;
    color: #fafbff;
    outline: none;
    border-width: 0;
    border-radius: 4px;
    font-size: 12px;
  }
}
</style>